Public Class FeedbackDescriptions
    Inherits System.Web.UI.Page
    Dim oFdbk As gaFeedBack.FeedBackAdmin
    Public strErr, Derection As String
    Public pageid As String = "fbadmindesc"
    Public NextDisplayOrder, DisplayOrder As String
    Public DescriptionID As Integer
    Public DescriptionText As String
    Public strHtml As String

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub
    Protected WithEvents Director As System.Web.UI.WebControls.Button

    'NOTE: The following placeholder declaration is required by the Web Form Designer.
    'Do not delete or move it.
    Private designerPlaceholderDeclaration As System.Object

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If Not IsPostBack Then
            strErr = ""
            strHtml = ""
            InitiFeedBCKDesc()

        Else

            '-----	deleting a description if requested
            If Not IsNothing(Request.QueryString("del")) Then
                oFdbk = New gaFeedBack.FeedBackAdmin
                oFdbk.DBConnectstring = Application("DSN")
                oFdbk.DescriptionID = CInt(Request.QueryString("del"))
                oFdbk.DeleteFeedbkConts(pageid)

            End If

            '-----	changing display order if requested
            If Not IsNothing(Request.QueryString("up")) Or Not IsNothing(Request.QueryString("down")) Then
                '-----	getting the selected description id
                DescriptionID = 0
                If Not IsNothing(Request.QueryString("up")) Then
                    Derection = "up"
                    DescriptionID = CInt(Request.QueryString("up"))

                ElseIf Not IsNothing(Request.QueryString("down")) Then
                    Derection = "down"
                    DescriptionID = CInt(Request.QueryString("down"))
                End If
                oFdbk = New gaFeedBack.FeedBackAdmin
                oFdbk.DBConnectstring = Application("DSN")
                oFdbk.MoveUpDown(DescriptionID, Derection)

            End If
        End If
    End Sub
    Public Sub InitiFeedBCKDesc()

        '-----	initializing NextDisplayOrder, which is used for 'Add New' form.
        Dim rst As New DataSet
        'Dim strHtml As String
        Dim i As Integer
        strHtml = ""
        NextDisplayOrder = 1
        '-----	getting current list of email recipients
        oFdbk = New gaFeedBack.FeedBackAdmin
        oFdbk.DBConnectstring = Application("DSN")
        rst = oFdbk.GetCurrentConts(pageid)

        If rst.Tables(0).Rows.Count Then
            strHtml = "<table border='0' cellpadding='1' cellspacing='1'>"
            strHtml += "<tr><td align='middle' nowrap><font face='arial' size='1'>DESCRIPTION</font>"
				
            strHtml += "</td><td align='middle' nowrap><font face='arial' size='1'>&nbsp;</font></td></tr>"
				
            'If rst.Tables(0).Rows.Count > 0 Then
            For i = 0 To rst.Tables(0).Rows.Count - 1
                DescriptionID = rst.Tables(0).Rows(i).Item("DescriptionID")
                DescriptionText = rst.Tables(0).Rows(i).Item("DescriptionText")
                DisplayOrder = CInt(rst.Tables(0).Rows(i).Item("DisplayOrder"))
                NextDisplayOrder = DisplayOrder + 1
                strHtml += "<tr><td bgcolor='dddddd' nowrap>"
                strHtml += "<font face='arial' size='2'>" & DescriptionText & "</font></td><td nowrap>"

                strHtml += "<table border='0' cellpadding='0' cellspacing='0'>"
                strHtml += "<tr><td nowrap>"
                strHtml += "	<font face='arial' size='2'><a href='FeedbackDescriptions.asp?del=" & DescriptionID & "'>Delete Description</a></font>"

                strHtml += "	</td><td nowrap><font face='arial' size='2'>&nbsp;</font></td><td nowrap>"

                strHtml += "	<font face='arial' size='2'><a href='FeedbackDescriptions.asp?up=" & DescriptionID & "'>Move Up</a>"
                strHtml += "</font></td><td nowrap><font face='arial' size=2>&nbsp;</font></td><td nowrap>"
                strHtml += "<font face='arial' size='2'><a href='FeedbackDescriptions.asp?down=" & DescriptionID & ">'>Move Down</a>"
                strHtml += "</font></td></tr></table> </td></tr>"
            Next
            strHtml += "</table>"
        Else
            strHtml += "<font face='arial' size='2'>No feedback descriptions found.</font><br>"

        End If

        strHtml += "<hr>"
        'Response.Write(strHtml)

    End Sub

    Private Sub Director_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Director.Click
        'If Request.Form("Director").count > 0 Then
        'If Request.Form("Director") = "Add Description" Then
        DescriptionText = Trim(Request.Form("DescriptionText"))
        NextDisplayOrder = CInt(Request.Form("NextDisplayOrder"))
        If Len(DescriptionText) > 0 Then
            oFdbk = New gaFeedBack.FeedBackAdmin
            oFdbk.DBConnectstring = Application("DSN")
            oFdbk.DescriptionText = DescriptionText
            oFdbk.NextDisplayOrder = NextDisplayOrder
            oFdbk.AddConts(pageid)
        End If
       
    End Sub
End Class
